//
//  UIImage+BundleName.m
//  EpubSDK
//
//  Created by linziyuan on 16/12/5.
//  Copyright © 2016年 creative. All rights reserved.
//

#import "UIImage+BundleName.h"
#import <objc/runtime.h>

@implementation UIImage (BundleName)

+ (void)load {
    Method fromMethod = class_getClassMethod([self class], @selector(imageNamed:));
    Method toMethod = class_getClassMethod([self class], @selector(jrsdk_bundelImageNamed:));
    
    method_exchangeImplementations(fromMethod, toMethod);
}

+ (UIImage *)jrsdk_bundelImageNamed:(NSString *)name {

    UIImage *img = [UIImage imageNamed:name inBundle:[NSBundle bundleForClass:NSClassFromString(@"JReaderSDKManager")] compatibleWithTraitCollection:nil];
    if (!img) {
        img = [UIImage jrsdk_bundelImageNamed:name];
    }
    return img;
}

@end
